package snafu.framework.agents;

import snafu.framework.actions.AbstractAction;
import snafu.framework.objects.WorldObject;
import snafu.framework.objects.WorldObjectItself;
import snafu.framework.objects.WorldObjectView;
import snafu.framework.states.State;
import snafu.framework.view.Access;
import snafu.framework.view.View;
import snafu.framework.worlds.WorldMap;
import snafu.utility.Cast;

public class AgentView extends WorldObjectView implements Agent, View {

	/**
	 * Initiates a new view of the given agent.
	 * 
	 * @param access
	 *            the access type
	 * @param agent
	 *            the original agent
	 */
	public AgentView(Access access, WorldObjectItself<AgentView> agent) {
		super(access, agent);
	}

	/**
	 * Creates a view of the agent's state with the same access as this agent.
	 */
	@Override
	public State getState() {
		return (Cast.cast(object, AgentItself.class)).state.createView(access);
	}
	
	@Override
	public boolean canPercept(WorldObject object) {
		return false;
	}

	@Override
	public Class<? extends AgentBrain> getBrain() {
		return ((Agent) object).getBrain();
	}

	/**
	 * Returns {@link Empty#action() the empty action}, since views can't act.
	 */
	@Override
	public AbstractAction act(WorldMap perception) {
		return null;
	}

	@Override
	public String toString() {
		return object.toString();
	}
}